home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gtlayout.lha
/
Source
/
LTP_LayoutGadgets.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-09-09
|
30KB
|
1,126 lines
/*
** GadTools layout toolkit
**
** Copyright © 1993-1998 by Olaf `Olsen' Barthel
** Freely distributable.
**
** :ts=4
*/
#ifndef _GTLAYOUT_GLOBAL_H
#include "gtlayout_global.h"
#endif
#include "Assert.h"
#ifdef DO_BOOPSI_KIND /* Support code */
/*****************************************************************************/
#include <dos/dosextens.h>
/*****************************************************************************/
STATIC VOID
LocalAddPart(STRPTR Base,STRPTR Name)
{
LONG Len = strlen(Base);
if(Base[Len - 1] != ':')
strcat(Base,"/");
strcat(Base,Name);
}
STATIC struct Library *
OpenClass(STRPTR Name)
{
struct Library *Result;
Result = OpenLibrary(Name,0);
if(Result == NULL)
{
struct Process * Process = (struct Process *)FindTask(NULL);
UBYTE LocalBuffer[256];
LONG i,Len;
Len = strlen(Name);
for(i = Len - 1 ; i >= 0 ; i--)
{
if(Name[i] == '/' || Name[i] == ':')
{
Name = &Name[i + 1];
break;
}
}
if(Process->pr_Task.tc_Node.ln_Type == NT_PROCESS && Process->pr_HomeDir != NULL)
{
strcpy(LocalBuffer,"PROGDIR:Classes/Gadgets");
LocalAddPart(LocalBuffer,Name);
Result = OpenLibrary(LocalBuffer,0);
}
if(!Result)
{
strcpy(LocalBuffer,":Classes/Gadgets");
LocalAddPart(LocalBuffer,Name);
if(!(Result = OpenLibrary(LocalBuffer,0)))
{
strcpy(LocalBuffer,"Gadgets");
LocalAddPart(LocalBuffer,Name);
if(!(Result = OpenLibrary(LocalBuffer,0)))
Result = OpenLibrary(Name,0);
}
}
}
return(Result);
}
#endif /* DO_BOOPSI_KIND */
/*****************************************************************************/
VOID
LTP_LayoutGadgets(LayoutHandle *Handle,ObjectNode *Group,LONG Left,LONG Top,LONG PlusWidth,LONG PlusHeight)
{
if(!Handle->Failed)
{
STATIC const struct TagItem NoUnderscoreVanillaTags[] =
{
{TAG_DONE}
};
STATIC const struct TagItem VanillaTags[] =
{
{GT_Underscore, '_'},
{TAG_DONE}
};
STATIC const struct TagItem DisabledTags[] =
{
{GT_Underscore, '_' },
{GA_Disabled, TRUE},
{TAG_DONE}
};
STATIC const struct TagItem NoUnderscoreDisabledTags[] =
{
{GA_Disabled, TRUE},
{TAG_DONE}
};
struct NewGadget NewGadget;
struct Gadget * Gadget;
struct Gadget * Extra;
struct TagItem * Tags;
ULONG page;
ObjectNode * Node;
if(!Handle->List)
{
if(!(Handle->Previous = CreateContext(&Handle->List)))
{
Handle->Failed = TRUE;
return;
}
}
NewGadget.ng_TextAttr = Handle->TextAttr;
NewGadget.ng_VisualInfo = Handle->VisualInfo;
Group->Special.Group.Visible = TRUE;
SCANPAGE(Group,Node,page)
{
if(Node->Type != FRAME_KIND && Node->Type != IMAGE_KIND && Node->Type != BLANK_KIND && Node->Type != BOX_KIND && Node->Type != XBAR_KIND && Node->Type != YBAR_KIND)
{
Extra = NULL;
if(Node->GroupIndent)
{
NewGadget.ng_LeftEdge = Node->Left + 4;
NewGadget.ng_TopEdge = Node->Top + 2;
NewGadget.ng_Width = Node->Width - (4 + 4);
NewGadget.ng_Height = Node->Height - (2 + 2);
}
else
{
NewGadget.ng_LeftEdge = Node->Left;
NewGadget.ng_TopEdge = Node->Top;
NewGadget.ng_Width = Node->Width;
NewGadget.ng_Height = Node->Height;
}
NewGadget.ng_GadgetText = Node->Label ? Node->Label : (STRPTR)"";
NewGadget.ng_GadgetID = Node->ID;
NewGadget.ng_UserData = Node;
if(Node->NoKey)
{
if(Node->Disabled)
{
if(!V39 && (Node->Type == MX_KIND || Node->Type == LISTVIEW_KIND))
Tags = (struct TagItem *)NoUnderscoreVanillaTags;
else
Tags = (struct TagItem *)NoUnderscoreDisabledTags;
}
else
Tags = (struct TagItem *)NoUnderscoreVanillaTags;
}
else
{
if(Node->Disabled)
{
if(!V39 && (Node->Type == MX_KIND || Node->Type == LISTVIEW_KIND))
Tags = (struct TagItem *)VanillaTags;
else
Tags = (struct TagItem *)DisabledTags;
}
else
Tags = (struct TagItem *)VanillaTags;
}
switch(Node->LabelPlace)
{
case PLACE_LEFT:
NewGadget.ng_Flags = PLACETEXT_LEFT;
break;
case PLACE_RIGHT:
NewGadget.ng_Flags = PLACETEXT_RIGHT;
break;
case PLACE_ABOVE:
NewGadget.ng_Flags = PLACETEXT_ABOVE;
break;
case PLACE_BELOW:
NewGadget.ng_Flags = PLACETEXT_BELOW;
break;
case PLACE_IN:
NewGadget.ng_Flags = PLACETEXT_IN;
break;
default:
NewGadget.ng_Flags = NULL;
break;
}
if(Node->HighLabel)
NewGadget.ng_Flags |= NG_HIGHLABEL;
Gadget = NULL; /* Always initialize this before entering the switch table. */
switch(Node->Type)
{
#ifdef DO_BOOPSI_KIND
{
case BOOPSI_KIND:
{
struct Gadget *Link;
if(Node->Special.BOOPSI.Link != NIL_LINK && Node->Special.BOOPSI.TagLink)
{
if(!(Link = LTP_FindGadgetLinear(Handle,Node->Special.BOOPSI.Link)))
{
Handle->Failed = TRUE;
return; /* Note: must return since we are in a loop that
* creates all gadgets for the current page.
*/
}
}
else
Link = NULL;
if(Node->Special.BOOPSI.ClassLibraryName)
{
if(!(Node->Special.BOOPSI.ClassBase = OpenClass(Node->Special.BOOPSI.ClassLibraryName)))
{
break;
}
}
if(Node->Special.BOOPSI.FullWidth)
{
NewGadget.ng_LeftEdge = Node->Special.BOOPSI.Parent->Left;
NewGadget.ng_Width = Node->Special.BOOPSI.Parent->Width;
}
if(Node->Special.BOOPSI.FullHeight)
{
NewGadget.ng_TopEdge = Node->Special.BOOPSI.Parent->Top;
NewGadget.ng_Height = Node->Special.BOOPSI.Parent->Height;
}
Gadget = NewObject(Node->Special.BOOPSI.ClassInstance,Node->Special.BOOPSI.ClassName,
GA_Left, NewGadget.ng_LeftEdge,
GA_Top, NewGadget.ng_TopEdge,
GA_Width, NewGadget.ng_Width,
GA_Height, NewGadget.ng_Height,
GA_Disabled, Node->Disabled,
GA_ID, Node->ID,
GA_UserData, Node,
Link ? Node->Special.BOOPSI.TagLink : TAG_IGNORE, Link,
Handle->BOOPSIPrevious ? GA_Previous : TAG_IGNORE, Handle->BOOPSIPrevious,
Node->Special.BOOPSI.TagTextAttr ? Node->Special.BOOPSI.TagTextAttr : TAG_IGNORE, Handle->TextAttr,
Node->Special.BOOPSI.TagDrawInfo ? Node->Special.BOOPSI.TagDrawInfo : TAG_IGNORE, Handle->DrawInfo,
Node->Special.BOOPSI.TagScreen ? Node->Special.BOOPSI.TagScreen : TAG_IGNORE, Handle->Screen,
Node->Special.BOOPSI.ClassTags ? TAG_MORE : TAG_DONE, Node->Special.BOOPSI.ClassTags);
break;
}
}
#endif /* DO_BOOPSI_KIND */
#ifdef DO_POPUP_KIND
{
case POPUP_KIND:
Gadget = NewObject(LTP_PopupClass,NULL,
GA_Left, NewGadget.ng_LeftEdge,
GA_Top, NewGadget.ng_TopEdge,
GA_Width, NewGadget.ng_Width,
GA_Height, NewGadget.ng_Height,
GA_Disabled, Node->Disabled,
GA_ID, Node->ID,
GA_UserData, Node,
GA_RelVerify, TRUE,
PIA_Labels, Node->Special.Popup.Choices,
PIA_Active, Node->Current,
PIA_Font, Handle->TextAttr,
PIA_CentreActive, Node->Special.Popup.CentreActive,
PIA_AspectX, Handle->AspectX,
PIA_AspectY, Handle->AspectY,
Handle->BOOPSIPrevious ? GA_Previous : TAG_IGNORE,Handle->BOOPSIPrevious,
TAG_DONE);
break;
}
#endif /* DO_POPUP_KIND */
#ifdef DO_TAB_KIND
{
case TAB_KIND:
if(Node->Special.Tab.FullWidth)
{
NewGadget.ng_LeftEdge = Handle->TopGroup->Left - Left;
NewGadget.ng_Width = Handle->TopGroup->Width + PlusWidth;
NewGadget.ng_LeftEdge += Handle->Screen->WBorLeft;
NewGadget.ng_Width -= Handle->Screen->WBorLeft + Handle->Screen->WBorRight;
}
else
{
NewGadget.ng_LeftEdge = Node->Special.Tab.Parent->Left;
NewGadget.ng_Width = Node->Special.Tab.Parent->Width;
}
Gadget = NewObject(LTP_TabClass,NULL,